﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

//public class Request
//{
//    public NetRequest netquest;

//    public Request ( NetRequest netRequest)
//    {
//        this.netquest = netRequest;
//    }
//}

public class RequestCollection  {

    Dictionary<int, RequestBase> m_RequestDict = new Dictionary<int, RequestBase>();
    public Dictionary<int, RequestBase> requestDict => m_RequestDict;

    public static object dictLock = new object();
   
    public void AddRequest(int seq,RequestBase requestBase)
    {
        //lock (RequestCollection.dictLock)
        {
            if (m_RequestDict.ContainsKey(seq))
            {
                Debug.LogError("AddRequest  ContainsKey:" + seq);
                return;
            }
      
            m_RequestDict[seq] = requestBase;
        }
    }

    public RequestBase GetNetRequest(int seq)
    {
        RequestBase res = null;
        //lock (RequestCollection.dictLock)
        {
            if (m_RequestDict.ContainsKey(seq))
            {
                res = m_RequestDict[seq];
            }
        }
        return res;
    }

    public void RemoveRequest(int seq)
    {
        //lock (RequestCollection.dictLock)
        {
            //GameDebug.LogShowy($"RequestCollection RemoveRequest :{seq}");
            m_RequestDict.Remove(seq);
        }
    }

    public void DoRemoveRequest()
    {
        
    }
    
}
